﻿Imports DTO
Imports System.Data.SqlClient
Public Class CChiTietPhieuTraDAO
    Public Function ThemChiTietPhieuTra(ByRef _phieutra As CChiTietPhieuTraDTO) As Integer
        Using cn As SqlConnection = CDataProvider.Connect()
            Dim cm As New SqlCommand("uspThemChiTietPhieuTra", cn)
            cm.CommandType = CommandType.StoredProcedure
            Dim para As SqlParameter = New SqlParameter("@masach", _phieutra.MaSach)
            cm.Parameters.Add(para)
            para = New SqlParameter("@ngaymuon", _phieutra.NgayMuon)
            cm.Parameters.Add(para)
            para = New SqlParameter("@songaymuon", _phieutra.SoNgayMuon)
            cm.Parameters.Add(para)
            para = New SqlParameter("@tienphat", _phieutra.TienPhat)
            cm.Parameters.Add(para)
            para = New SqlParameter("@maphieutra", _phieutra.MaPhieuTra)
            cm.Parameters.Add(para)
            para = New SqlParameter("@maphieumuon", _phieutra.MaPhieuMuon)
            cm.Parameters.Add(para)
            para = New SqlParameter("@machitietphieumuon", _phieutra.MaChiTietPhieuMuon)
            cm.Parameters.Add(para)
            para = New SqlParameter("@ma", _phieutra.Ma)
            para.Direction = ParameterDirection.Output
            cm.Parameters.Add(para)
            Dim n As Integer = cm.ExecuteNonQuery()
            cn.Close()
            _phieutra.Ma = cm.Parameters("@ma").Value
            Return n
        End Using
    End Function
End Class
